package com.runjian.rundo.iot.agent.common.entity;

import java.util.HashMap;
import java.util.Map;

/**
 * 设备测量数据对象（1.0版本前使用，现在保留以减少代码的改动）
 *
 * @author : LiGang
 */
public class UnifiedPublishEntity {

    private final Map<String, Object> data;

    private String externalId;

    private String time;

    private String gatewayId;
    private String model;

    private transient boolean hasSeries;

    public UnifiedPublishEntity() {
        this.data = new HashMap<>();
    }

    public UnifiedPublishEntity(String externalId, String gatewayId, String time) {
        this.data = new HashMap<>();
        this.externalId = externalId;
        this.gatewayId = gatewayId;
        this.time = time;

    }

    public Map<String, Object> getData() {
        return data;
    }

    public UnifiedPublishEntity buildItem(String type, String series, Number value, String unit) {
        this.data.put(series, value);
        hasSeries = true;
        return this;
    }

    public UnifiedPublishEntity buildItem(String series, Number value) {
        this.data.put(series, value);
        hasSeries = true;
        return this;
    }

    public UnifiedPublishEntity buildItem(String series, Object value) {
        this.data.put(series, value);
        hasSeries = true;
        return this;
    }

    public UnifiedPublishEntity buildItem(Map<String, Object> data) {
        this.data.putAll(data);
        hasSeries = true;
        return this;
    }

    public String getExternalId() {
        return externalId;
    }

    public void setExternalId(String externalId) {
        this.externalId = externalId;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getModel() {
        return this.model;
    }

    public String getGatewayId() {
        return gatewayId;
    }

    public void setGatewayId(String gatewayId) {
        this.gatewayId = gatewayId;
    }

    public boolean isHasSeries() {
        return hasSeries;
    }
}
